<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="(items,index) in arr" :key="index">{{items}}<button @click="click1(index)">删除</button></li>
        </ul>
        <button @click="click2">生成</button>
        </div>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                arr:[1,2,3]
            },
            methods: {
                click1(index){
                    this.arr.splice(index,1)

                },
                click2(){
                    var num = Math.floor(Math.random()*20)
                    this.arr.push(num);
                }
            }
        })
    </script>
</body>

</html>